package com.itheima.servise.impl;

import com.itheima.mapper.EmpMapper;
import com.itheima.pojo.ClassCount;
import com.itheima.servise.ClazzStudentCountServise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ClazzStudentCountServiseImpl implements ClazzStudentCountServise {
    @Autowired
    private EmpMapper empMapper;

    @Override
    public List<Map> countStudentDegree() {
        List<Map> maps = empMapper.CountStudentDegree();
        return maps;
    }

    @Override
    public ClassCount countStudentCount() {
        List<Map> maps = empMapper.classStudentCount();
        ClassCount classCount = new ClassCount();
        List<Object> classList = maps.stream().map(m -> m.get("className")).toList();
        List<Object> dataList = maps.stream().map(m -> m.get("value")).toList();
        classCount.setClazzList(classList);
        classCount.setDataList(dataList);
        return classCount;
    }
}
